package resources;

import org.eclipse.californium.core.coap.CoAP;
import org.eclipse.californium.core.server.resources.CoapExchange;

/**
 * describe:
 *
 * @author helloworldyu
 * @data 2017/12/6
 */
public class WarningResource extends BaseResource{
	public static final String URL = "devices/${deviceId}/warning";

	public WarningResource() {
		super(URL);
		getAttributes().setTitle("Sensor Warning operation");
	}

	@Override
	public void handlePOST(CoapExchange exchange) {
		byte[] requestPayload = exchange.getRequestPayload();
		System.out.println("post 的数据:"+new String(requestPayload));
		exchange.respond(CoAP.ResponseCode.CREATED,"post warning ok");
	}

	@Override
	public void handleDELETE(CoapExchange exchange) {
		exchange.respond(CoAP.ResponseCode.DELETED,"delete warning ok");
	}

	@Override
	public void handlePUT(CoapExchange exchange) {
		exchange.respond(CoAP.ResponseCode.CHANGED,"put warning ok");
	}

	@Override
	public void handleGET(CoapExchange exchange) {
		exchange.respond(CoAP.ResponseCode.CONTENT,"get warning ok");
	}
}